﻿@{
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
}

@model LineOfBusiness.Poco.AD_tblSetupSequences

@Html.LOBHtmlHelper().Busy("pupopBusy")
@{Html.LOBHtmlHelper().tdLable("120");}

<style>
 fieldset {
    margin: 8px;
    border: 1px solid silver;
    padding: 8px;    
    border-radius: 4px;
}
legend{
    padding: 2px;        
}
</style>
 
<div>
    <form id="frm">
        <table style="width:100%;padding-left:15px;padding-right:15px">
            <tr>
                <td class="tdLabel">
                    @Html.LOBHtmlHelper().Label("lblSequenceID", "Sequence ID")
                </td>
                <td >
                    @Html.LOBHtmlHelper().InputFor("SequenceID", InputType.Text, "40")
                </td>
                <td></td>
            </tr>
        
            <tr>
                <td class="tdLabel">
                    @Html.LOBHtmlHelper().Label("lblSequenceName", "Sequence Name")
                    @Html.LOBHtmlHelper().Label("lblSequenceName2", "Sequence Name 2")
                </td>
                <td>
                    @Html.LOBHtmlHelper().InputFor("SequenceName", InputType.Text,1 )
                    @Html.LOBHtmlHelper().InputFor("SequenceName2", InputType.Text, 1)
                
                </td>
                <td style="width:20px">
                    <img src="@Html.BaseUrl()Content/default/images/change.png" width="16px" height="16px" alt="" onclick= "imageClick()"/> 
                </td>
            </tr>

            <tr>
                <td class="tdLabel">
                    @Html.LOBHtmlHelper().Label("lblStop", "Stop")
                </td>
                <td>
                    @Html.LOBHtmlHelper().CheckBoxFor(o=>o.Stop)
                </td>
                <td></td>
            </tr>

        </table>

        <fieldset>
            <legend>                
                @Html.LOBHtmlHelper().Label("lblSequences", "Sequences")

            </legend>
            <table style="width:100%">                                        
                <tr>
                    <td class="tdLabel">                            
                        @Html.LOBHtmlHelper().Label("lblMaxLenght", "Max Lenght")
                    </td>
                    <td>          
                        @Html.LOBHtmlHelper().InputFor("MaxLenght", InputType.Text, 0)      
                        @*@Html.LOBHtmlHelper().NumericInt("MaxLenght",  0, new {style = "width:100%;text-align:right"}, null)*@
                    </td>
                    <td></td>
                    <td class="tdLabel"> 
                        @Html.LOBHtmlHelper().Label("lblStep", "Step")
                                                                           
                    </td>
                    <td>
                        @Html.LOBHtmlHelper().InputFor("Step", InputType.Text, 0)      
                        @*@Html.LOBHtmlHelper().NumericInt("Step", 0,new {style = "width:100%;text-align:right"}, null)                       *@
                    </td>
                </tr>                                        
                <tr>
                    <td class="tdLabel">                            
                        @Html.LOBHtmlHelper().Label("lblFixedString", "Fixed String")
                    </td>
                    <td>                
                        @Html.LOBHtmlHelper().InputFor("FixedString", InputType.Text, 0)      
                        @*@Html.LOBHtmlHelper().Input("FixedString", InputType.Text , 0,new {style = "width:100%"})*@
                    </td>
                    <td></td>
                    <td class="tdLabel">
                        @Html.LOBHtmlHelper().Label("lblLastNumber", "Last Number")
                    </td>
                    <td>                            
                        @Html.LOBHtmlHelper().InputFor("LastNumber", InputType.Text, 0)      
                        @*@Html.LOBHtmlHelper().NumericInt("LastNumber", 0,new {style = "width:100%;text-align:right"}, null)*@
                    </td>                    
                </tr>
                    
                <tr>
                    <td class="tdLabel">                            
                        @Html.LOBHtmlHelper().Label("lblPrefix", "Prefix")
                    </td>
                    <td>                            
                        @Html.LOBHtmlHelper().CheckBoxFor(o=>o.Prefix)
                    </td>
                    <td></td>
                    <td class="tdLabel">
                        @Html.LOBHtmlHelper().Label("lblAutoReset", "Auto Reset")
                    </td>
                    <td>                            
                        @Html.LOBHtmlHelper().CheckBoxFor(o=>o.AutoReset)
                    </td>                    
                </tr>

                <tr>
                    <td class="tdLabel">                            
                        @Html.LOBHtmlHelper().Label("lblHyphen", "Hyphen")
                    </td>
                    <td>
                        @Html.LOBHtmlHelper().InputFor("Hyphen", InputType.Text, 0)                               
                        @*@Html.LOBHtmlHelper().Input("Hyphen", InputType.Text , 0,new {style = "width:100%"})*@
                    </td>
                    <td></td>
                    <td class="tdLabel">
                        @Html.LOBHtmlHelper().Label("lblIntervalType", "Interval Type")
                    </td>
                    <td>                           
                        @Html.LOBHtmlHelper().ComboBoxFor("IntervalType", "L0029" , 0,new {style = "width:100%"})
                    </td>                    
                </tr>

                <tr>
                    <td class="tdLabel">                            
                        @Html.LOBHtmlHelper().Label("lblIncludeDate", "Include Date")
                    </td>
                    <td>                         
                        @Html.LOBHtmlHelper().CheckBoxFor(o=>o.IncludeDate)
                    </td>      
                    <td></td>
                    <td></td>                                 
                </tr>
                <tr>
                    <td class="tdLabel">
                        @Html.LOBHtmlHelper().Label("lblFormatType", "Format Type")
                    </td>
                    <td>                         
                        @Html.LOBHtmlHelper().ComboBoxFor("FormatType", "L0028" , 0,new {style = "width:100%"})
                    </td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                                                  
            </table>           
        </fieldset>

        <div id="_blank" style="height:25px"></div>
    </form>
</div>

<div class="Line">
</div>

<div  style="text-align:right">
    <div class="buttons">
        @if(ViewBag.Edit!=-1)
        {
            <button id="btnSave" class="positive" onclick= "SavePopup()">
                <img src="@Html.BaseUrl()Content/images/toolbar/save.png" alt="" /> 
                @Html.LOBHtmlHelper().C("Save") 
            </button> 
        }
        <button class="positive" onclick= "Close()">
            <img src="@Html.BaseUrl()Content/images/toolbar/close.png" alt="" /> 
            @Html.LOBHtmlHelper().C("Close")
        </button> 
    </div>
</div>

<script type="text/javascript">

    var codeBasePopup = new CodeBasePopup();

    $(document).ready(function () {

        codeBasePopup.init('@ViewBag.Edit', "SequenceID", "@Url.Action("Save","SetupSequences")", '@Model.SequenceID', "", 80);

        HideControl("lblSequenceName2");
        HideControl("SequenceName2");

        codeBasePopup.IsReadOnly("LastNumber", true);

        setTimeout(function () { $("#SequenceID").focus(); }, 500);

        onPropertyChanged('IncludeDate', '', codeBasePopup.GetValue("IncludeDate"));
        onPropertyChanged('AutoReset', '', codeBasePopup.GetValue("AutoReset"));
        codeBasePopup.setOrderTab('SequenceID,SequenceName,MaxLenght,FixedString,Prefix,Hyphen,IncludeDate,FormatType,Step,AutoReset,IntervalType');

        if ('@Model.RowSystem' == 'True')
        {
            codeBasePopup.IsReadOnly("SequenceID", true);
            codeBasePopup.IsReadOnly("MaxLenght", true);
            
        }
    });

    function onPropertyChanged(name, old, value) {
        if (name == "IncludeDate") {
            if (value == true) {
                codeBasePopup.IsReadOnly("FormatType", false);                
            }
            else
                codeBasePopup.IsReadOnly("FormatType", true);
        }
        else if (name == "AutoReset")
        {
            if (value == true) {
                codeBasePopup.IsReadOnly("IntervalType", false);
            }
            else
                codeBasePopup.IsReadOnly("IntervalType", true);
        }
    }

    function imageClick() {
        if (document.getElementById("SequenceName2").style.display == "none") {
            ShowControl("SequenceName2");
            ShowControl("lblSequenceName2");
            HideControl("lblSequenceName");
            HideControl("SequenceName");
        }
        else {
            ShowControl("SequenceName");
            ShowControl("lblSequenceName");
            HideControl("lblSequenceName2");
            HideControl("SequenceName2");
        }
    }

    function SavePopup() {
        codeBasePopup.SavePopup();
    }

    function Close() {
        codeBasePopup.Close();
    }
</script>